﻿

namespace System.Extensions.IO
{
  using System.IO;

  /// <summary>
  /// Extension methods for a <see cref="FileInfo"/>.
  /// </summary>
  public static class FileInfoExtensions
  {
    /// <summary>
    /// Adds a file to the <b>Recent Documents</b> menu using the Shell.
    /// </summary>
    /// <param name="fileInfo">The <see cref="FileInfo"/> object that represents the file to be added to the menu.</param>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Cannot add a directory to the recent items list, only files work")]
    public static void AddToRecentDocuments(this FileInfo fileInfo)
    {
      NativeMethods.SHAddToRecentDocs(fileInfo.FullName);
    }

    /// <summary>
    /// Deletes the file or directory to the recycle bin using the Shell.
    /// </summary>
    /// <param name="fileInfo">The <see cref="FileInfo"/> object that represents the file to delete.</param>
    public static void DeleteToRecycleBin(this FileSystemInfo fileInfo)
    {
      NativeMethods.DeleteToRecycleBin(fileInfo.FullName, false);
    }

    /// <summary>
    /// Deletes a file or directory to the recycle bin using the Shell.  Optional confirmation dialog.
    /// </summary>
    /// <param name="fileInfo">The <see cref="FileInfo"/> object that represents the file to delete.</param>
    /// <param name="showConfirmation">Whether to show the stock confirmation dialog for this action.</param>
    public static void DeleteToRecycleBin(this FileSystemInfo fileInfo, bool showConfirmation)
    {
      NativeMethods.DeleteToRecycleBin(fileInfo.FullName, showConfirmation);
    }
  }
}
